<?php namespace Zm345\Com\SDK\OpenLib\Copen\Enterpr\Product;use Zm345\Com\SDK\OpenLib\Copen\AQueryCopen;class ProductCatsAdd extends AQueryCopen{protected$apiParams=array();public function setFields($fieldStr=null){$this->apiParams['fields']=(string)$fieldStr;return$this;}public function add($data=null){$this->apiParams['data'][]=$data;return$this;}public function check(){if(empty($this->apiParams['fields'])||empty($this->apiParams['data'])){$this->errorCode='error-param';$this->errorInfo='必须设置fields或data项';return false;}return true;}protected function getQueryStr(){$queryStr='REPLACE INTO '.$this->tbPrefix.'enterpr_product_category ('.$this->apiParams['fields'].') VALUES';$db=$this->db;$valParts=[];foreach($this->apiParams['data']as$itemData){array_walk($itemData,function(&$val)use($db){if(!is_null($val))$val=$db->quote($val);});$valParts[]='('.implode(',',$itemData).')';}$queryStr.=implode(',',$valParts).';';$this->apiParams=array();return$queryStr;}}?>